package com.william.taskrobot.service;

import com.william.taskrobot.model.BussessCategoryInfo;
import com.william.taskrobot.model.RuleInfo;
import com.william.taskrobot.model.SessionInfo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * BussnessService class
 * 核心处理类
 * @author william
 * @date 2021/1/14
 */
@Service
public class BussnessService {
    @Autowired
    private RuleService ruleService;
    /**
     * 传入用户输入内容，和通话上下文信息
     * @param content
     * @return
     */
    public String getAnswer(String content, SessionInfo sessionInfo) throws Exception{
        if(sessionInfo.getCategoryInfo()!=null){
            //多轮会话，
        }
        else
        {
            //第一次会话，先根据输入内容进行意图识别
            RuleInfo ruleInfo=RuleFactory.create();
            SessionInfo session=new SessionInfo();
            for(BussessCategoryInfo info:ruleInfo.categoryInfoList){
                if(ruleService.check(info,session)){
                    session.setCategoryInfo(info);
                    //利用规则处理

                }
            }
            throw new Exception("系统无法识别问题");
        }
        return StringUtils.EMPTY;
    }
}
